package com.ruoyi.zxjd.work.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.zxjd.work.domain.WorkProgress;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable4;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.mapper.WorkTemplateTable4Mapper;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable4Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 纪检监察干部违纪违法案件情况Service业务层处理
 * 
 * @author lcc
 * @date 2021-02-26
 */
@Service
public class WorkTemplateTable4ServiceImpl implements IWorkTemplateTable4Service 
{
    @Autowired
    private WorkTemplateTable4Mapper workTemplateTable4Mapper;
    @Autowired
    private WorkProgressServiceImpl workProgressService;

    /**
     * 查询纪检监察干部违纪违法案件情况
     * 
     * @param id 纪检监察干部违纪违法案件情况ID
     * @return 纪检监察干部违纪违法案件情况
     */
    @Override
    public WorkTemplateTable4 selectWorkTemplateTable4ById(Long id)
    {
        return workTemplateTable4Mapper.selectWorkTemplateTable4ById(id);
    }

    /**
     * 查询纪检监察干部违纪违法案件情况列表
     * 
     * @param workTemplateTable4 纪检监察干部违纪违法案件情况
     * @return 纪检监察干部违纪违法案件情况
     */
    @Override
    public List<WorkTemplateTable4> selectWorkTemplateTable4List(WorkTemplateTable4 workTemplateTable4)
    {
        return workTemplateTable4Mapper.selectWorkTemplateTable4List(workTemplateTable4);
    }

    /**
     * 新增纪检监察干部违纪违法案件情况
     * 
     * @param workTemplateTable4 纪检监察干部违纪违法案件情况
     * @return 结果
     */
    @Override
    public int insertWorkTemplateTable4(WorkProgressBO workProgressBO)
    {
        WorkProgress workProgress = workProgressBO.getWorkProgress();
        workTemplateTable4Mapper.deleteByProgressId(workProgress.getProgressId());
        List<WorkTemplateTable4> WorkTemplateTable4List = workProgressBO.getWorkTemplateTable4List();
        for (WorkTemplateTable4 Table : WorkTemplateTable4List) {
            Table.setCreateBy(ShiroUtils.getLoginName());
            Table.setCreateTime(DateUtils.getNowDate());
            Table.setProgressId(workProgress.getProgressId());
            workTemplateTable4Mapper.insertWorkTemplateTable4(Table);
        }
        return workProgressService.validate(workProgress);
    }

    /**
     * 修改纪检监察干部违纪违法案件情况
     * 
     * @param workTemplateTable4 纪检监察干部违纪违法案件情况
     * @return 结果
     */
    @Override
    public int updateWorkTemplateTable4(WorkTemplateTable4 workTemplateTable4)
    {
        workTemplateTable4.setUpdateBy(ShiroUtils.getLoginName());
        workTemplateTable4.setUpdateTime(DateUtils.getNowDate());
        return workTemplateTable4Mapper.updateWorkTemplateTable4(workTemplateTable4);
    }

    /**
     * 删除纪检监察干部违纪违法案件情况对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable4ByIds(String ids)
    {
        return workTemplateTable4Mapper.deleteWorkTemplateTable4ByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除纪检监察干部违纪违法案件情况信息
     * 
     * @param id 纪检监察干部违纪违法案件情况ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable4ById(Long id)
    {
        return workTemplateTable4Mapper.deleteWorkTemplateTable4ById(id);
    }

    /**
     * 查询纪检监察干部违纪违法案件情况
     * 
     * @param progressId
     * @return 纪检监察干部违纪违法案件情况
     */
    @Override
    public List<WorkTemplateTable4> selectWorkTemplateTable4ByProgressId(Long progressId)
    {
        return workTemplateTable4Mapper.selectWorkTemplateTable4ByProgressId(progressId);
    }

    /**
     * 查询纪检监察干部违纪违法案件情况
     * 
     * @param arrangeId
     * @return 纪检监察干部违纪违法案件情况
     */
    @Override
    public List<WorkTemplateTable4> selectWorkTemplateTable4ByArrangeId(Long arrangeId)
    {
        return workTemplateTable4Mapper.selectWorkTemplateTableByArrangeIdAndStatus(arrangeId);
    }
}
